package com.dahua.cglib;

import org.aopalliance.intercept.MethodInvocation;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author chen_MingLiang
 * @version 1.0
 * @date 2020/1/28 22:31
 */
public class MyMethodInterceptor implements MethodInterceptor {

	@Override
	public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
		System.out.println("cglib proxy");
		//执行父类方法.o是父类对象,父类没有参数就传null
		Object returnVal = methodProxy.invokeSuper(o, null);
		//什么情况需要返回?就看逻辑
		return returnVal;
	}
}
